#!/usr/bin/env bash


# 看看目录是否存在
ls -al ~/.ssh

# 生成密钥
ssh-keygen -t rsa -C "347969164@qq.com"

# 操作
Enter file in which to save the key (/home/qy/.ssh/id_rsa):  #【按回车】
Enter passphrase (empty for no passphrase): #【输入密码】
# 密码 xiefei123
Enter same passphrase again: # 【再次输入密码】
# 密码 xiefei123


# 密钥文件目录
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:joUMKG8+3KkO8dbpRyvHYgOG8ufydZNL3jkMYYB6mO8 347969164@qq.com
The key's randomart image is:
+---[RSA 2048]----+
|     .           |
|   .. .          |
|. .+.  .         |
| o+ .o .o        |
|..oo  o.S.       |
|o*oo.o.+..       |
|oo*o=oo.*o       |
| oo+E.=+ +o.     |
| .o*+*  o o.     |
+----[SHA256]-----+


# 得到 agent pid
eval $(ssh-agent -s)
Agent pid 22939

# 将 ssh 私钥添加到 ssh 代理中。如果使用不同的名称创建了密钥, 或者添加了具有不同名称的现有密钥, 请用私钥文件的名称替换该命令中的 id_rsa
ssh-add ~/.ssh/id_rsa

# 复制 SSH key 到剪切板

# 到Git 添加公钥
SSH Key: 347969164@qq.com/182.92.78.60/解飞
指纹： SHA256:joUMKG8+3KkO8dbpRyvHYgOG8ufydZNL3jkMYYB6mO8
公钥内容 ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCg+MqOEq+s2KxymbEXG6jjn8qXmhWP9u39r9VVmbKcebRv80XiZ+cC+H6Dkt75LzrLnoJzt1ocYuvtTbh1eblmqZFNHWr260pumgOKR/TgIFRA8W4ecV4dOJqAchMPaBy2R5j0FzUlFrs27P3pwf6nbfPwiaO5n9iJooUiver80cZUrtQ2sPIajCjZ8drA3N9BtPXACtc7C45A+RkLgUKUawdJGYw3+1NW+ZeBdQZ+FzKAvQX2bySUb/BEsezgPSeQqw2NqgkxT8jZ9IlE007TLxfNwRpi6CeUJwfrkNjA4Zv8yv4ZR24N1MvmMAgCLxV9SZpzf3t+2OxMV2WB6YL5 347969164@qq.com

# 确认
ssh -T git@gitee.com

# The authenticity of host 'gitee.com (180.97.125.228)' can't be established.
# ECDSA key fingerprint is SHA256:FQGC9Kn/eye1W8icdBgrQp+KkGYoFgbVr17bmjey0Wc.
# ECDSA key fingerprint is MD5:27:e5:d3:f7:2a:9e:eb:6c:93:cd:1f:c1:47:a3:54:b1.
# Are you sure you want to continue connecting (yes/no)? yes
# 输入 yes
# Warning: Permanently added 'gitee.com,180.97.125.228' (ECDSA) to the list of known hosts.
# Enter passphrase for key '/root/.ssh/id_rsa':
# 输入公钥密码

# Hi 简简单单OnlineZuozuo! You've successfully authenticated, but GITEE.COM does not provide shell access.
# 成功


